package com.zzjson.thread;

import java.util.concurrent.TimeUnit;

/**
 * <p>****************************************************************************</p>
 * <p><b>Copyright © 2010-2019 shuncom team All Rights Reserved<b></p>
 * <ul style="margin:15px;">
 * <li>Description : com.zzjson.thread</li>
 * <li>Version     : 1.0.0</li>
 * <li>Creation    : 2019年08月09日</li>
 * <li>@author     : zzy0_0</li>
 * </ul>
 * <p>****************************************************************************</p>
 */
public class InterruptDemo {
	private static int i;

	public static void main(String[] args) throws InterruptedException {
		Thread thread = new Thread(() -> {
			//在一个线程类中，存在一个成员属性是 isInterrupt,并且是volitale修饰的,默认是false,判断当前线程是否是中断状态
			while (!Thread.currentThread().isInterrupted()) {
				/*try {
					Thread.sleep(1000000);
				} catch (InterruptedException e) {
					e.printStackTrace();
				}*/

				i++;
			}
		});
		thread.start();
		TimeUnit.SECONDS.sleep(1);
		// 把isInterrupt设置为 true
		thread.interrupt();


	}
}